package com.cwnu.controller;

import com.cwnu.entity.Article;
import com.cwnu.entity.FeedBack;
import com.cwnu.entity.PageBean;
import com.cwnu.entity.Result;
import com.cwnu.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;
    // 新增反馈
    @PostMapping("/add")
    public Result add(@RequestBody FeedBack feedBack) {
        boolean flag = feedbackService.add(feedBack);
        if (flag) return Result.success();
        return Result.error("提交失败");
    }
    // 查询所有未删除的反馈
    @PostMapping("/getList")
    public Result getFeedbackList(@RequestBody Map<String, Object> params) {
        Integer pageNum = (Integer) params.get("pageNum");
        Integer pageSize = (Integer) params.get("pageSize");
        PageBean<FeedBack> pb= feedbackService.getFeedbackList(pageNum, pageSize);
        return Result.success(pb);
    }


}
